Working with Popups

I.       Creating a Popup

F    From the OpenInsight IDE choose New, Windows UI Tools, Popup Box to launch the Popup Designer.

 

 From the Popup Designer, enter the following:

a.       Title: Sales Territiory

b.      Source: Select Rows From Table

c.       Table: SALES_SALESTERRITORY

d.      Selection Criteria: BY @ID

e.       Column ID: TERRITORYID, NAME, GROUP, MODIFIEDDATE.  Adjust the column Width and Justification.

 

 
From the Popup Box Property Panel set the Popup Behavior and Appearance.

 

 

 From the OpenInsight IDE, choose File, Save to save the popup.  Enter the popup name SALESTERRITORY in the Entity Name.

 

 

From the OpenInsight IDE, choose Test Run to execute the popup.

 

 

II.      Adding Popup Functionality to a Window

 

The most common use of a Popup is to provide users with a list of choices during data entry.  The following procedure will demonstrate how to add a button to an existing form and the Event Handler necessary to execute the Popup and place the results within a data field.

 

Open the SALESTERRITORY form and it will load in the Form Designer.

Select Open, OpenInsight Forms from the OpenInsight IDE.  Choose the SALESTERRITORY form.

From the Common Controls tool panel on the left side of the Form Designer select the Push Button control and drag it on to the form.

 

 

Place the control on the form by moving the mouse cursor to a location on the form where you want to place the control.  The mouse cursor changes to the control’s icon with a + appearing to the left and above the icon as soon as the mouse cursor enters the form.  The + is used to help position the control.  Click the left mouse button where you want to place the control.  The control is displayed in the form in the selected state (with handles visible). 

 

 

Click on the button.  The Push Button Properties window will appear in the Property Panel on the right side of the form.  Change the Name of the control to “BTN_CHOOSE_TERRITORY” and the Text that is displayed on the control to “Choose Territory”.

 

 

Click on the Events Tab on the Property Panel to display the QuickEvent dialog box.  Under Action, Click, open the properties for the Click Event.

 

The CLICK event will be chosen by default.  Check the Quick Event checkbox.  Set the Event Action:

 

Type: Send an event

Target:@WINDOW.EF_TERRITORYID

Message: OPTIONS

 

 

 Click on the TerritoryID control.  Here we will set the event properties for the LostFocus event and the Options event.

 

Click on the EventScript check box for the LostFocus event.  This will launch the Event Editor.  In the Editor type the following code:

 

// Lostfocus fires when you move to another control

// OI will enforce the required property here

// But, the user needs to click on the Choose Territory button

// So, modify the process to skip the lostfocus processing

// if the next control is the search button

// FocusCtrl parameter is the next control. It looks like windowname.Control

// Here we parse out the control name, see if it is the button.

focusCtrl = Field(FocusId, '.', 2, 99)

If focusCtrl == "BTN_CHOOSE_TERRITORY" Then

   // Return 0 will skip the normal processing

   return 0

End Else

   // Return 1 will continue on to the normal processing

   Return 1

end

 

 

      Click on the EventScript check box for the Options event.  This will launch the Event Editor.  In the Editor type the following code:

 

Declare Subroutine Set_Property, Send_Event

Declare Function Popup

//execute the popup and place the value chosen in the retval variable

retval = Popup(@Window, "", "SALESTERRITORY")

//place the value in the retval variable into the TerritoryID control on the Form

Set_Property(CtrlEntID,"DEFPROP",retval)

//send the LOSTFOCUS event to initiate the read of the record

Send_Event(CtrlEntID,"LOSTFOCUS")

return 0

 

 

      Select File, Compile from the OpenInsight IDE.  Any errors will be displayed in the Output Panel at the bottom of the OpenInsight IDE.  If the syntax is correct the status line will display “The syntax is correct”.

 

This will cause a popup to display when the Choose Territory button is clicked.  The user may choose a Territory.  The value chosen will be placed into the EF_TERRITORYID control on the SALESTERRITORY form.  When the EF_TERRITORYID field loses focus a read of the TERRITORYID placed into the field will occur.

 

      Select File, Save from the OpenInsight IDE.  This will save the code.  Click the View Form button on the Toolbar to return to the form.

 

Choose File, Save to save the form.

 

Test run the form and click the Choose Territory button to launch the popup.  Select a record, click OK and the record will be read and loaded into the form.